cmake_minimum_required(VERSION 2.8.4)
project(crag)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -DdSINGLE -D__STRICT_ANSI__ -Wall -Wextra -Wfatal-errors -fno-exceptions -fno-unwind-tables")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DPROFILE -fno-unwind-tables")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -fno-rtti -Wno-strict-aliasing")

set(SOURCE_FILES
    src/applet/Applet.cpp
    src/applet/Applet.h
    src/applet/AppletInterface.h
    src/applet/AppletInterface_Impl.h
    src/applet/Engine.cpp
    src/applet/Engine.h
    src/core/app.cpp
    src/core/app.h
    src/core/config.h
    src/core/ConfigEntry.cpp
    src/core/ConfigEntry.h
    src/core/ConfigManager.cpp
    src/core/ConfigManager.h
    src/core/core.h
    src/core/counted_object.h
    src/core/debug.cpp
    src/core/debug.h
    src/core/double_buffer.h
    src/core/enum_bitset.h
    src/core/Enumeration.h
    src/core/EventWatcher.cpp
    src/core/EventWatcher.h
    src/core/floatOps.h
    src/core/function_ref.h
    src/core/GlobalResourceManager.cpp
    src/core/GlobalResourceManager.h
    src/core/HashString.h
    src/core/intOps.h
    src/core/intrusive_list.h
    src/core/memory.cpp
    src/core/memory.h
    src/core/object_pool.h
    src/core/pointer_union.h
    src/core/profile.cpp
    src/core/profile.h
    src/core/Random.cpp
    src/core/Random.h
    src/core/Resource.cpp
    src/core/Resource.h
    src/core/ResourceHandle.h
    src/core/ResourceManager.cpp
    src/core/ResourceManager.h
    src/core/ring_buffer.h
    src/core/Roster.cpp
    src/core/Roster.h
    src/core/Singleton.h
    src/core/Statistics.cpp
    src/core/Statistics.h
    src/core/TypeId.cpp
    src/core/TypeId.h
    src/core/union_buffer.h
    src/core/verify.h
    src/core/windows.h
    src/entity/gfx/Planet.cpp
    src/entity/gfx/Planet.h
    src/entity/gfx/Puff.cpp
    src/entity/gfx/Puff.h
    src/entity/gfx/Thruster.cpp
    src/entity/gfx/Thruster.h
    src/entity/physics/PlanetBody.cpp
    src/entity/physics/PlanetBody.h
    src/entity/sim/AnimatController.cpp
    src/entity/sim/AnimatController.h
    src/entity/sim/AnimatThruster.cpp
    src/entity/sim/AnimatThruster.h
    src/entity/sim/CameraController.cpp
    src/entity/sim/CameraController.h
    src/entity/sim/Contact.cpp
    src/entity/sim/Contact.h
    src/entity/sim/Genome.cpp
    src/entity/sim/Genome.h
    src/entity/sim/HoverThruster.cpp
    src/entity/sim/HoverThruster.h
    src/entity/sim/MoonShader.cpp
    src/entity/sim/MoonShader.h
    src/entity/sim/MouseObserverController.cpp
    src/entity/sim/MouseObserverController.h
    src/entity/sim/ObserverInput.cpp
    src/entity/sim/ObserverInput.h
    src/entity/sim/PlanetController.cpp
    src/entity/sim/PlanetController.h
    src/entity/sim/PlanetShader.cpp
    src/entity/sim/PlanetShader.h
    src/entity/sim/RoverThruster.cpp
    src/entity/sim/RoverThruster.h
    src/entity/sim/Sensor.cpp
    src/entity/sim/Sensor.h
    src/entity/sim/Thruster.cpp
    src/entity/sim/Thruster.h
    src/entity/sim/TouchObserverController.cpp
    src/entity/sim/TouchObserverController.h
    src/entity/sim/UfoController1.cpp
    src/entity/sim/UfoController1.h
    src/entity/sim/UfoController2.cpp
    src/entity/sim/UfoController2.h
    src/entity/sim/VehicleController.cpp
    src/entity/sim/VehicleController.h
    src/entity/sim/VernierThruster.cpp
    src/entity/sim/VernierThruster.h
    src/entity/SpawnEntityFunctions.cpp
    src/entity/SpawnEntityFunctions.h
    src/entity/SpawnPlayer.cpp
    src/entity/SpawnPlayer.h
    src/entity/SpawnSkybox.cpp
    src/entity/SpawnSkybox.h
    src/form/CalculateNodeScoreFunctor.cpp
    src/form/CalculateNodeScoreFunctor.h
    src/form/CastRay.cpp
    src/form/CastRay.h
    src/form/defs.h
    src/form/Engine.cpp
    src/form/Engine.h
    src/form/ForEachChildNode.h
    src/form/ForEachFaceInSphere.h
    src/form/ForEachNodeFace.h
    src/form/Formation.cpp
    src/form/Formation.h
    src/form/GatherExpandableNodesFunctor.h
    src/form/Mesh.cpp
    src/form/Mesh.h
    src/form/MeshProperties.h
    src/form/Node.cpp
    src/form/Node.h
    src/form/NodeBuffer.cpp
    src/form/NodeBuffer.h
    src/form/Object.cpp
    src/form/Object.h
    src/form/Point.cpp
    src/form/Point.h
    src/form/PointBuffer.cpp
    src/form/PointBuffer.h
    src/form/Polyhedron.cpp
    src/form/Polyhedron.h
    src/form/Quaterna.h
    src/form/QuaternaBuffer.cpp
    src/form/QuaternaBuffer.h
    src/form/RayCastResult.cpp
    src/form/RayCastResult.h
    src/form/Scene.cpp
    src/form/Scene.h
    src/form/Shader.h
    src/form/Surrounding.cpp
    src/form/Surrounding.h
    src/geom/Distance.h
    src/geom/Intersection.h
    src/geom/Magnitude.h
    src/geom/Matrix.h
    src/geom/Matrix33.h
    src/geom/Matrix44.h
    src/geom/MatrixOps.h
    src/geom/Plane.h
    src/geom/Quaternion.h
    src/geom/Ray.h
    src/geom/Space.h
    src/geom/Sphere.h
    src/geom/Transformation.h
    src/geom/Triangle.h
    src/geom/Vector.h
    src/geom/Vector2.h
    src/geom/Vector3.h
    src/geom/Vector4.h
    src/gfx/object/Ball.cpp
    src/gfx/object/Ball.h
    src/gfx/object/Light.cpp
    src/gfx/object/Light.h
    src/gfx/object/MeshObject.cpp
    src/gfx/object/MeshObject.h
    src/gfx/object/Object.cpp
    src/gfx/object/Object.h
    src/gfx/object/SearchLight.cpp
    src/gfx/object/SearchLight.h
    src/gfx/object/Skybox.cpp
    src/gfx/object/Skybox.h
    src/gfx/object/Surrounding.cpp
    src/gfx/object/Surrounding.h
    src/gfx/axes.h
    src/gfx/BufferObject.h
    src/gfx/Color.h
    src/gfx/Debug.cpp
    src/gfx/Debug.h
    src/gfx/defs.h
    src/gfx/Engine.cpp
    src/gfx/Engine.h
    src/gfx/Font.cpp
    src/gfx/Font.h
    src/gfx/Frustum.cpp
    src/gfx/Frustum.h
    src/gfx/GenerateShadowVolumeMesh.h
    src/gfx/glHelpers.cpp
    src/gfx/glHelpers.h
    src/gfx/Image.cpp
    src/gfx/Image.h
    src/gfx/IndexBufferObject.h
    src/gfx/IndexedVboResource.h
    src/gfx/LightType.h
    src/gfx/LitVertex.cpp
    src/gfx/LitVertex.h
    src/gfx/LodParameters.h
    src/gfx/Mesh.h
    src/gfx/Messages.h
    src/gfx/NonIndexedVboResource.h
    src/gfx/PlainVertex.cpp
    src/gfx/PlainVertex.h
    src/gfx/Pov.cpp
    src/gfx/Pov.h
    src/gfx/Program.cpp
    src/gfx/Program.h
    src/gfx/Quad.cpp
    src/gfx/Quad.h
    src/gfx/RegisterResources.cpp
    src/gfx/RegisterResources.h
    src/gfx/RenderBuffer.cpp
    src/gfx/RenderBuffer.h
    src/gfx/Scene.cpp
    src/gfx/Scene.h
    src/gfx/SetCameraEvent.h
    src/gfx/SetLodParametersEvent.h
    src/gfx/SetSpaceEvent.h
    src/gfx/Shader.cpp
    src/gfx/Shader.h
    src/gfx/ShadowMap.h
    src/gfx/ShadowVolume.h
    src/gfx/Texture.h
    src/gfx/Texture2d.cpp
    src/gfx/Texture2d.h
    src/gfx/TextureCubeMap.cpp
    src/gfx/TextureCubeMap.h
    src/gfx/Uniform.cpp
    src/gfx/Uniform.h
    src/gfx/VboResource.h
    src/gfx/VertexBufferObject.h
    src/ipc/Daemon.h
    src/ipc/EngineBase.h
    src/ipc/Fiber.cpp
    src/ipc/Fiber.h
    src/ipc/FiberAndroid.cpp
    src/ipc/FiberAndroid.h
    src/ipc/FiberPosix.cpp
    src/ipc/FiberPosix.h
    src/ipc/FiberWin.cpp
    src/ipc/FiberWin.h
    src/ipc/Future.h
    src/ipc/Handle.h
    src/ipc/Handle_Impl.h
    src/ipc/Listener.h
    src/ipc/ListenerInterface.cpp
    src/ipc/ListenerInterface.h
    src/ipc/MessageQueue.h
    src/ipc/MessageQueue_Impl.h
    src/ipc/ObjectBase.h
    src/ipc/Uid.cpp
    src/ipc/Uid.h
    src/physics/Body.cpp
    src/physics/Body.h
    src/physics/BoxBody.cpp
    src/physics/BoxBody.h
    src/physics/ContactInterface.h
    src/physics/CylinderBody.cpp
    src/physics/CylinderBody.h
    src/physics/defs.h
    src/physics/Engine.cpp
    src/physics/Engine.h
    src/physics/GhostBody.cpp
    src/physics/GhostBody.h
    src/physics/Location.cpp
    src/physics/Location.h
    src/physics/MeshBody.cpp
    src/physics/MeshBody.h
    src/physics/PassiveLocation.cpp
    src/physics/PassiveLocation.h
    src/physics/RayCast.cpp
    src/physics/RayCast.h
    src/physics/SphereBody.cpp
    src/physics/SphereBody.h
    src/scripts/GameScript.cpp
    src/scripts/GameScript.h
    src/scripts/InitSpace.cpp
    src/scripts/InitSpace.h
    src/scripts/MainScript.cpp
    src/scripts/MainScript.h
    src/scripts/MonitorOrigin.cpp
    src/scripts/MonitorOrigin.h
    src/scripts/RegulatorScript.cpp
    src/scripts/RegulatorScript.h
    src/scripts/TestScript.cpp
    src/scripts/TestScript.h
    src/sim/Controller.cpp
    src/sim/Controller.h
    src/sim/defs.h
    src/sim/Engine.cpp
    src/sim/Engine.h
    src/sim/Entity.cpp
    src/sim/Entity.h
    src/sim/EntityFunctions.cpp
    src/sim/EntityFunctions.h
    src/sim/gravity.cpp
    src/sim/gravity.h
    src/smp/ReadersWriterMutex.cpp
    src/smp/ReadersWriterMutex.h
    src/smp/Semaphore.cpp
    src/smp/Semaphore.h
    src/smp/SimpleMutex.h
    src/smp/smp.cpp
    src/smp/smp.h
    src/smp/Thread.cpp
    src/smp/Thread.h
    src/smp/vector.h
    src/main.cpp
    src/pch.cpp
    src/pch.h)

add_executable(crag ${SOURCE_FILES})

if (CRAG_RPI)
	include_directories("src" "/usr/include/SDL2" "linux/include/SDL2" "../rpi/include/SDL2" "/opt/vc/include")

	find_library(BCM_HOST bcm_host /opt/vc/lib)
	find_library(GLES2_LIBRARY GLESv2 /opt/vc/lib)
	find_library(SDL2_LIBRARY SDL2 /usr/lib ../rpi/lib)
	find_library(SDL2_IMAGE_LIBRARY SDL2_image /usr/lib ../rpi/lib)
	find_library(ODE_LIBRARY ode /usr/lib)
	target_link_libraries(crag ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${ODE_LIBRARY} ${GLES2_LIBRARY} ${BCM_HOST} "dl" "pthread" "stdc++" "m" "rt")
else (CRAG_RPI)
	include_directories("src" "/usr/include/SDL2" "linux/include/SDL2")

	# TODO: Given these don't appear to be needed by RPi, try removing them here
	find_package(OpenGL REQUIRED)
	find_library(SDL2_LIBRARY SDL2 linux/lib)  # /usr/lib
	find_library(SDL2_IMAGE_LIBRARY SDL2_image linux/lib)   # /usr/lib
	find_library(ODE_LIBRARY ode /usr/lib)
	target_link_libraries(crag ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${ODE_LIBRARY} ${OPENGL_LIBRARIES} "dl" "pthread" "stdc++" "m")
endif (CRAG_RPI)

#include (src/PrecompiledHeader.cmake)
#add_precompiled_header(crag src/pch.h)
